import http from './../../../base/api/public'
import querystring from 'querystring'
import qs from 'qs'


/*登陆*/
export const login = params => {
  //let loginRequest = querystring.stringify(params)
  let loginRequest = qs.stringify(params);

  return http.requestPostForm('/auth/login',loginRequest);
};

/*退出*/
export const logout = params => {
  sessionStorage.removeItem('activeUser');
  return http.requestPost('/auth/userlogout');
};

/**
 * 根据用户id获取用户信息
 * @param id
 * @returns {*|Promise|Promise<unknown>|Promise}
 */
export const user_get = id => {
  return http.requestQuickGet('/api/ucenter/user/get/' + id)
};

/**
 * 编辑用户信息
 * @param id
 * @param params
 * @returns {*|Promise|Promise<unknown>|Promise}
 */
export const user_edit = (id, params) => {
  return http.requestPut('/api/ucenter/user/edit/' + id, params)
};

/**
 * 修改密码
 * @param userId
 * @param password
 * @returns {*|Promise|Promise<unknown>|Promise}
 */
export const user_editPwd = (userId, password) => {
  return http.requestPut('/api/ucenter/user/editPwd/' + userId + '?password=' + password);
};
